cmake_minimum_required(VERSION 3.10)
project(rewise LANGUAGES C)

include(GNUInstallDirs)

find_package(ZLIB REQUIRED)

set(rewise_SRC_FILES
    src/CP1252.c
    src/exefile.c
    src/pkzip.c
    src/print.c
    src/reader.c
    src/rewise.c
    src/wildcard.c
    src/wiseoverlay.c
    src/wisescript.c
)

add_executable(rewise ${rewise_SRC_FILES})
target_include_directories(rewise SYSTEM PRIVATE ${ZLIB_INCLUDE_DIRS})

if("${ZLIB_LIBRARIES}" STREQUAL "")
    message(WARNING "ZLIB_LIBRARIES wasn't set, manually setting to ZLIB::ZLIB")
    set(ZLIB_LIBRARIES "ZLIB::ZLIB")
endif()

target_link_libraries(rewise PRIVATE ${ZLIB_LIBRARIES})

install(TARGETS rewise RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
install(FILES rewise.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
